﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Migrations;
using MusicLibrary.DataModels;


namespace MusicLibrary.Data
{
    public static class Seeder
    {
        public static void Seed(ApplicationDbContext db)
        {
            db.Albums.AddOrUpdate(
                x => x.Title,
                new Album("Album One", "Zed","http://upload.wikimedia.org/wikipedia/commons/f/fc/Z.png"),
                new Album("Album Two", "X-Ray","http://upload.wikimedia.org/wikipedia/commons/8/8e/OS_X-Logo.svg"),
                new Album("Album Three", "Yankee","http://dailydropcap.com/images/Y-7.jpg")
                );
            db.SaveChanges();

            db.Songs.AddOrUpdate(
                x => x.Title,
                new Song(1, "Song 1-a"),
                new Song(1, "Song 2-a"),
                new Song(1, "Song 3-a"),
                new Song(1, "Song 4-a"),
                new Song(2, "Song 1-b"),
                new Song(2, "Song 2-b"),
                new Song(2, "Song 3-b"),
                new Song(2, "Song 4-b"),
                new Song(3, "Song 1-c"),
                new Song(3, "Song 2-c"),
                new Song(3, "Song 3-c"),
                new Song(3, "Song 4-c")
                );
            db.SaveChanges();

            db.Tags.AddOrUpdate(
                x => x.Name,
                new Tag("Pop"),
                new Tag("Rock"),
                new Tag("Jazz"),
                new Tag("Retro"),
                new Tag("Upbeat"),
                new Tag("Minor"),
                new Tag("Smooth")
                );

            db.SaveChanges();

            db.TagSongs.AddOrUpdate(
                x => new { x.TagId, x.SongId },
                new TagSong(5, 1),
                new TagSong(6, 2),
                new TagSong(7, 3),
                new TagSong(5, 4),
                new TagSong(6, 5),
                new TagSong(7, 6),
                new TagSong(5, 7),
                new TagSong(6, 8),
                new TagSong(7, 9),
                new TagSong(5, 10),
                new TagSong(6, 11),
                new TagSong(6, 12),
                new TagSong(7, 12)

                );
            db.SaveChanges();

            db.TagAlbums.AddOrUpdate(
                x => new { x.TagId,x.AlbumId },
                new TagAlbum(1, 1),
                new TagAlbum(2, 3),
                new TagAlbum(3, 2),
                new TagAlbum(4, 1)
                );
            db.SaveChanges();

        }
    }
}
